<?php
class Test3{
    public $name;

	public function __set($name, $value)
    {
        echo "---- __set()被调用 ----<br>";
        echo "参数:{$name}:{$value}<br>";
    }

    public function __get($name)
    {
        echo "---- __get()被调用 ----<br>";
        return $name."->返回值<br>";
    }
}
$t = new Test3();
$t->name = '测试名称';
$t->age = 10; // 给不存在的属性赋值
echo $t->age; // 获取不存在属性的值
